package com.scu.servlet;

import com.scu.dao.mCommentDao;
import com.scu.entity.mComment;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

@WebServlet(name = "CommentAddServlet", value = "/CommentAddServlet")
public class CommentAddServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            String comment_content = request.getParameter("comment_content");
//        String post_content = request.getParameter("post_content");
//        String type = request.getParameter("type");
            //String id = request.getParameter("id");

            Date date = new Date();
            SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

            System.out.println(comment_content);
           mComment comment = new mComment();
            comment.setComment_content(comment_content);
            //post.setIs_illegal(0);
            comment.setDates(ft.format(date));

            try {
                new mCommentDao().insert(comment);
            } catch (SQLException e) {
                e.printStackTrace();
            }

            System.out.println("123");
        }
    }

